package com.android.assistivetouch;

public class Log {

    private static final String TAG = "AssistiveTouch";

    private static final boolean VERBOSE = true;
    private static final boolean DEBUG = true;
    private static final boolean INFO = true;
    private static final boolean WARN = true;
    private static final boolean ERROR = true;

    public static int v(Object prefix, String msg) {
        if (VERBOSE) {
            return android.util.Log.v(TAG, getPrefix(prefix) + msg);
        } else {
            return 0;
        }
    }

    public static int v(Object prefix, String msg, Throwable tr) {
        if (VERBOSE) {
            return android.util.Log.v(TAG, getPrefix(prefix) + msg, tr);
        } else {
            return 0;
        }
    }

    public static int d(Object prefix, String msg) {
        if (DEBUG) {
            return android.util.Log.d(TAG, getPrefix(prefix) + msg);
        } else {
            return 0;
        }
    }

    public static int d(Object prefix, String msg, Throwable tr) {
        if (DEBUG) {
            return android.util.Log.d(TAG, getPrefix(prefix) + msg, tr);
        } else {
            return 0;
        }
    }

    public static int i(Object prefix, String msg) {
        if (INFO) {
            return android.util.Log.i(TAG, getPrefix(prefix) + msg);
        } else {
            return 0;
        }
    }

    public static int i(Object prefix, String msg, Throwable tr) {
        if (INFO) {
            return android.util.Log.i(TAG, getPrefix(prefix) + msg, tr);
        } else {
            return 0;
        }
    }

    public static int w(Object prefix, String msg) {
        if (WARN) {
            return android.util.Log.w(TAG, getPrefix(prefix) + msg);
        } else {
            return 0;
        }
    }

    public static int w(Object prefix, String msg, Throwable tr) {
        if (WARN) {
            return android.util.Log.w(TAG, getPrefix(prefix) + msg, tr);
        } else {
            return 0;
        }
    }

    public static int e(Object prefix, String msg) {
        if (ERROR) {
            return android.util.Log.e(TAG, getPrefix(prefix) + msg);
        } else {
            return 0;
        }
    }

    public static int e(Object prefix, String msg, Throwable tr) {
        if (ERROR) {
            return android.util.Log.e(TAG, getPrefix(prefix) + msg, tr);
        } else {
            return 0;
        }
    }

    private static String getPrefix(Object obj) {
        if (obj == null) {
            return "";
        }
        if (obj instanceof String) {
            return "[" + (String)obj + "]";
        } else {
            return "[" + obj.getClass().getSimpleName() + "]";
        }
    }
}

